package ups.Wind;

import java.util.ArrayList;
import java.io.File;
import org.htmlparser.Parser;

public class WindManager {
	ArrayList<WindRecord> results = new ArrayList<WindRecord>();

	public WindManager( ArrayList<File> files ) {
		for( File file : files ) {
			search( file, results );
		}
	}
	
	public WindManager( File file ) {
		search( file, results );
	}
	
	private void search( File file, ArrayList<WindRecord> results ) {
		try {
			Parser p = new Parser( file.toString() );
			WindVisitor wv = new WindVisitor( results );
			p.visitAllNodesWith( wv );
		} catch ( Exception e ) {
			e.printStackTrace();
		}
	}
	
	public void printResults() {
		for( WindRecord rec : results ) {
			System.out.println( rec.toString() );
		}
	}
	
	public ArrayList<WindRecord> getResults() {
		return results;
	}
}